package com.ruoyi.credit.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.credit.mapper.EvaTaskDetailMapper;
import com.ruoyi.credit.domain.EvaTaskDetail;
import com.ruoyi.credit.service.IEvaTaskDetailService;
import com.ruoyi.common.core.text.Convert;

/**
 * 评价任务详情Service业务层处理
 *
 * @author zhulei
 * @date 2022-03-10
 */
@Service
public class EvaTaskDetailServiceImpl implements IEvaTaskDetailService
{
    @Autowired
    private EvaTaskDetailMapper evaTaskDetailMapper;

    /**
     * 查询评价任务详情
     *
     * @param taskDetailId 评价任务详情主键
     * @return 评价任务详情
     */
    @Override
    public EvaTaskDetail selectEvaTaskDetailByTaskDetailId(Long taskDetailId)
    {
        return evaTaskDetailMapper.selectEvaTaskDetailByTaskDetailId(taskDetailId);
    }

    /**
     * 查询评价任务详情列表
     *
     * @param evaTaskDetail 评价任务详情
     * @return 评价任务详情
     */
    @Override
    public List<EvaTaskDetail> selectEvaTaskDetailList(EvaTaskDetail evaTaskDetail)
    {
        return evaTaskDetailMapper.selectEvaTaskDetailList(evaTaskDetail);
    }

    /**
     * 新增评价任务详情
     *
     * @param evaTaskDetail 评价任务详情
     * @return 结果
     */
    @Override
    public int insertEvaTaskDetail(EvaTaskDetail evaTaskDetail)
    {
        evaTaskDetail.setCreateTime(DateUtils.getNowDate());
        return evaTaskDetailMapper.insertEvaTaskDetail(evaTaskDetail);
    }

    /**
     * 修改评价任务详情
     *
     * @param evaTaskDetail 评价任务详情
     * @return 结果
     */
    @Override
    public int updateEvaTaskDetail(EvaTaskDetail evaTaskDetail)
    {
        evaTaskDetail.setUpdateTime(DateUtils.getNowDate());
        if(null != evaTaskDetail.getScore()){
            evaTaskDetail.setStatus("1");
        }
        return evaTaskDetailMapper.updateEvaTaskDetail(evaTaskDetail);
    }

    /**
     * 批量删除评价任务详情
     *
     * @param taskDetailIds 需要删除的评价任务详情主键
     * @return 结果
     */
    @Override
    public int deleteEvaTaskDetailByTaskDetailIds(String taskDetailIds)
    {
        return evaTaskDetailMapper.deleteEvaTaskDetailByTaskDetailIds(Convert.toStrArray(taskDetailIds));
    }

    /**
     * 删除评价任务详情信息
     *
     * @param taskDetailId 评价任务详情主键
     * @return 结果
     */
    @Override
    public int deleteEvaTaskDetailByTaskDetailId(Long taskDetailId)
    {
        return evaTaskDetailMapper.deleteEvaTaskDetailByTaskDetailId(taskDetailId);
    }
}
